package com.meij.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.meij.MJApplaction;

public class Info extends com.util.Info {

	/***
	 * 用户是否登录
	 */
	public static boolean isLogin() {
		if (MJApplaction.userInfo == null) {
			return false;
		}
		if (TextUtils.isEmpty(MJApplaction.userInfo.getToken()) || TextUtils.isEmpty(MJApplaction.userInfo.getUserkey())) {
			return false;
		}
		return true;
	}

	/***
	 * 保存用户信息
	 */
	public static void saveUserInfo(Context context) {
		// 保存用户信息
		SharedPreferences preferences = context.getSharedPreferences("user", Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		Gson gson = new Gson();
		editor.putString("userinfo", gson.toJson(MJApplaction.userInfo));
		editor.commit();
	}
}
